#include <gtest/gtest.h>
#include "Parser.h"

//using ::testing::Return;

TEST(Parser, Status)
{

    // Setup
    list<AlarmStatus> alarmStatusList;
    string sDisarmedReady = "[100000010000--------],008,[f70000011008001c08020000000000],\"****DISARMED****  Ready to Arm  \"\r\n";
    string sArmedAway     = "[010105010000--------],008,[f70000011008050c0c020000000000],\"ARMED ***AWAY***You may exit now\"\r\n";
    string sArmedStay     = "[001003010000--------],008,[f70000011008038c08020000000000],\"ARMED ***STAY***                \"\r\n";
    string sTriggeredStay = "[001100010110--------],001,[f7000001100100800b020000000000],\"ALARM 01                        \"\r\n";
    Parser::eState state;
    Parser p;

    // verify that the alarm status list is empty
    EXPECT_EQ(true,alarmStatusList.empty());


    // Process the message
    p.Process((const unsigned char*)sDisarmedReady.c_str(),sDisarmedReady.size(), alarmStatusList);

    // verify that the alarm status message is still empty, we throw away the first message
    EXPECT_EQ(true,alarmStatusList.empty());

    // Process the message
    p.Process((const unsigned char*)sDisarmedReady.c_str(),sDisarmedReady.size(), alarmStatusList);


    // verify that the alarm status message is  not empty
    EXPECT_EQ(false,alarmStatusList.empty());

    // Process the message
    p.Process((const unsigned char*)sArmedAway.c_str(),sArmedAway.size(), alarmStatusList);

    // Process the message
    p.Process((const unsigned char*)sArmedStay.c_str(),sArmedStay.size(), alarmStatusList);

    // Process the message
    p.Process((const unsigned char*)sTriggeredStay.c_str(),sTriggeredStay.size(), alarmStatusList);

    // verify that the alarm status list is not empty
    EXPECT_EQ(false,alarmStatusList.empty());

    // check for Alarm Ready status & Not Triggered
     EXPECT_EQ(AlarmStatus::STATE_ALARM_READY, alarmStatusList.front().getAlarmState());
     EXPECT_EQ(false, alarmStatusList.front().isAlarmTriggered());
     alarmStatusList.pop_front();

     // verify that the alarm status list is not empty
     EXPECT_EQ(false,alarmStatusList.empty());

     // check for Alarm_Away Status & Not Triggered
     EXPECT_EQ(AlarmStatus::STATE_ALARM_AWAY, alarmStatusList.front().getAlarmState());
     EXPECT_EQ(false, alarmStatusList.front().isAlarmTriggered());
     alarmStatusList.pop_front();

     // verify that the alarm status list is not empty
     EXPECT_EQ(false,alarmStatusList.empty());

     // check for Alarm Stay Status & Not Triggered
     EXPECT_EQ(AlarmStatus::STATE_ALARM_STAY, alarmStatusList.front().getAlarmState());
     EXPECT_EQ(false, alarmStatusList.front().isAlarmTriggered());
     alarmStatusList.pop_front();


     // verify that the alarm status list is not empty
     EXPECT_EQ(false,alarmStatusList.empty());

     // check for Alarm_Stay Status & Triggered
     EXPECT_EQ(AlarmStatus::STATE_ALARM_STAY, alarmStatusList.front().getAlarmState());
     EXPECT_EQ(true, alarmStatusList.front().isAlarmTriggered());
     alarmStatusList.pop_front();

     // verify that the alarm status list is empty
     EXPECT_EQ(true,alarmStatusList.empty());




}


